package com.gzx.plugin.website.protocol.controller;

import com.gzx.plugin.website.protocol.bo.*;
import com.gzx.plugin.website.protocol.service.GzxMediationProtocolService;
import com.gzx.plugin.website.protocol.vo.GzxMediationProtocolOutVo;
import com.gzx.plugin.website.protocol.vo.GzxMediationProtocolVo;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.annotation.CommonNoRepeat;
import vip.xiaonuo.common.mvc.controller.BaseController;
import vip.xiaonuo.common.pojo.CommonResult;

import java.util.List;

/**
 * @author zjt
 * @description
 * @date 2025/4/15 16:01
 */
@RestController
@RequestMapping("/website/protocol")
public class GzxMediationProtocolController extends BaseController<GzxMediationProtocolAddOrEditBo, GzxMediationProtocolVo, GzxMediationProtocolQueryBo, GzxMediationProtocolService> {
    public GzxMediationProtocolController(GzxMediationProtocolService baseService) {
        super(baseService);
    }

    @CommonNoRepeat
    @CommonLog("调解协议导入")
    @PostMapping("/importExcel")
    public CommonResult<Void> importExcel(@RequestPart("mediationProtocolImportAddBo") GzxMediationProtocolImportAddBo mediationProtocolImportAddBo, @RequestPart("multipartFile") MultipartFile multipartFile) {
        baseService.importExcel(mediationProtocolImportAddBo, multipartFile);
        return CommonResult.ok();
    }

    @GetMapping("/preview/{id}")
    public CommonResult<GzxMediationProtocolOutVo> preview(@PathVariable Long id) {
        return CommonResult.data(baseService.preview(id));
    }

    @PostMapping("/rewr")
    public CommonResult<List<GzxMediationProtocolOutVo>> selectListByDebtorCardId(@RequestBody GzxMediationProtocolOutQueryBo mediationProtocolOutQueryBo, HttpServletRequest request) {
        return baseService.selectListByDebtorCardId(mediationProtocolOutQueryBo, request);
    }

    @PostMapping("/open/generate")
    public CommonResult<Void> selectListByDebtorCardId(@RequestBody List<GzxMediationProtocolExcelBo> mediationProtocolExcelBoList, HttpServletRequest request) {
        baseService.apiGenerateProtocol(mediationProtocolExcelBoList, request);
        return CommonResult.ok();
    }
}
